<h2><?=tr('Commands administration')?></h2>
<p class="backpage">&raquo; <?=fgsBase::linkPage(tr('Add a command'), 'admin_commands', array('add'))?> &middot; <?=fgsBase::linkPage(tr('Update command list from master'), 'admin_commands', array('retrieve'))?></p>
<?php

	if (!is_null($form)) {

		echo $form->output();
		
	} else {

		$commands = fgsCommands::get();

		if (!$commands)
			echo tr('No command has been defined yet');
		else {
			$tbl = new htmlTable();

			$tbl->setHeader('action', array(
				'width' => '50px',
			));
			$tbl->setHeader('gid', array(
				'title' => tr('Gid'),
				'width' => '10ex',
			));
			$tbl->setHeader('name', array(
				'title' => tr('Name'),
				'width' => '35ex',
			));
			$tbl->setHeader('os', array(
				'title' => tr('OS'),
				'width' => '7ex',
			));
			$tbl->setHeader('command', array(
				'title' => tr('Command'),
			));
			$tbl->setHeader('master', array(
				'width' => '5ex',
			));

			foreach ($commands as $n) {
				$tbl->set('gid', $n['gid']);
				$tbl->set('name', $n['name']);
				$tbl->set('os', $n['os']);
				$tbl->set('master', $n['is_master'] ? 'M' : 'L');
				$tbl->set('command', sprintf('<tt>%s</tt>', $n['command']));

				$actions = array();
				if (!$n['is_deleted']) {
					$actions[] = fgsBase::linkPage(fgsBase::image('del'), 'admin_commands', array('hide', $n['id']));
				} else {
					$tbl->setLineParam('class', 'disabled');
					$actions[] = fgsBase::linkPage(fgsBase::image('ok'), 'admin_commands', array('show', $n['id']));
				}
				$actions[] = fgsBase::linkPage(fgsBase::image('edit'), 'admin_commands', array('edit', $n['id']));

				$tbl->set('action', implode(' ', $actions));
					
				$tbl->push();
			}

			echo $tbl->render();
		}	

	}
	
?>
